package java_thinking.unit_9._9_9;

/**
 * @Description :
 * @author: cww
 * @DateTime: 2019-03-08 21:52
 */
interface Cycle {
    void cycle();
}
interface CycleFactory{
    Cycle getCycle();
}

class Unicycle implements Cycle{

    @Override
    public void cycle() {
        System.out.println("Unicycle");
    }
}

class Bicycle implements Cycle{

    @Override
    public void cycle() {
        System.out.println("Bicycle");
    }
}

class Tricycle implements Cycle{

    @Override
    public void cycle() {
        System.out.println("Tricycle");
    }
}

class UnicycleFatory implements CycleFactory{

    @Override
    public Cycle getCycle() {
        return new Unicycle();
    }
}

class BicycleFatory implements CycleFactory{

    @Override
    public Cycle getCycle() {
        return new Bicycle();
    }
}

class TricycleFatory implements CycleFactory{

    @Override
    public Cycle getCycle() {
        return new Tricycle();
    }
}

class UseCycle{
    public static void useCycle(CycleFactory factory){
        Cycle cycle = factory.getCycle();
        cycle.cycle();
    }

    public static void main(String[] args) {
        UseCycle.useCycle(new BicycleFatory());
        UseCycle.useCycle(new TricycleFatory());
    }
}